<template>
  <section class="page-head">
    <div>
      <svg
        id="svgIcon"
        viewBox="0 0 107 24"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
        xmlns:xlink="http://www.w3.org/1999/xlink"
        class="svg-icon icon-logo"
      >
        <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
          <g transform="translate(-24.000000, -16.000000)">
            <g transform="translate(24.000000, 16.000000)">
              <path
                d="M19.6549116,3.61285714 L19.6643655,3.558 L19.6549929,3.61238571 L17.2301799,3.61238571 L16.1743606,3.61238571 L13.7954369,3.61238571 L4.37471004,3.61238571 C5.23715582,3.0381 6.2702,2.70595714 7.37028032,2.70595714 L15.9002,2.70595714 L17.3904651,2.70595714 L19.8166578,2.70595714 L29.8785253,2.70595714 C30.9970835,2.70595714 32.0241116,3.04281429 32.8758145,3.61238571 L31.7821799,3.61238571 L19.6549929,3.61238571 Z M37.2014076,9.43452857 L40.3521064,9.43452857 L42.2432992,9.43452857 C42.3713554,9.61538571 42.5406647,9.76924286 42.7366165,9.88195714 L45.714998,11.5971 L44.10699,11.5971 L37.2598494,11.5971 C37.0501466,11.2071 36.9685,10.7498143 37.0492871,10.2933857 L37.2014076,9.43452857 Z M43.871504,15.7555286 L48.7088494,15.7555286 L51.1831707,15.7555286 C51.1943434,15.9136714 51.188757,16.0752429 51.1668414,16.2363857 C51.103243,16.7112429 50.8595924,18.0239571 50.6584839,19.0829571 L48.1841627,19.0829571 L45.7541024,19.0829571 C45.9040743,18.9312429 46.0265442,18.7512429 46.1030341,18.5433857 C46.3711787,17.8126714 46.0673675,17.0202429 45.4163434,16.6448143 L43.871504,15.7555286 Z M38.0940197,12.4286571 L44.9742486,12.4286571 L47.1593691,12.4286571 L48.1090478,12.9755143 C48.585606,13.2498 49.4136743,13.6925143 50.1274373,14.0692286 C50.5593048,14.2963714 50.8644052,14.6619429 51.0337145,15.0905143 L48.6182647,15.0905143 L42.7160759,15.0905143 L38.0940197,12.4286571 Z M37.6132932,7.10584286 L39.8551365,7.10584286 L43.1197108,7.10584286 C42.4643896,7.27512857 41.9719317,7.8687 41.9818153,8.60284286 L39.7691928,8.60284286 L37.3481566,8.60284286 L37.6132932,7.10584286 Z M38.0774325,4.61057143 L50.56979,4.61057143 L53.2082639,4.61057143 L52.913047,6.108 L40.6454325,6.108 L37.7895209,6.108 L37.9975048,4.93071429 C38.0168422,4.821 38.0456333,4.71471429 38.0774325,4.61057143 Z M40.6559606,2.70587143 L53.5831936,2.70587143 L53.4044305,3.61272857 L50.6679807,3.61272857 L38.6384305,3.61272857 C39.1369044,3.05344286 39.8609807,2.70587143 40.6559606,2.70587143 Z M14.3233036,19.5817286 L14.4053799,19.5817286 L13.6396209,23.9137286 L13.5493799,23.9137286 L11.1652996,23.9137286 L11.1648699,23.9137286 L4.72080562,23.9137286 C2.19706667,23.9137286 0.20102249,21.9611571 0.0123759036,19.5817286 L11.9306289,19.5817286 L14.3233036,19.5817286 Z M5.87202249,11.5970571 L3.30917912,11.5970571 L1.2688739,11.5970571 L1.65132369,9.43448571 L3.6911992,9.43448571 L6.25404257,9.43448571 L5.87202249,11.5970571 Z M5.03755141,19.0824 L2.56323012,19.0824 L-4.29718876e-05,19.0824 C0.00597309237,18.8526857 0.027888755,18.6199714 0.0691417671,18.3851143 L0.53409759,15.7554 L2.66249518,15.7554 L5.13681647,15.7554 L4.74276426,17.9839714 C4.67014177,18.3958286 4.79218193,18.7905429 5.03755141,19.0824 Z M5.25451647,15.0900857 L2.75011486,15.0900857 L0.651367871,15.0900857 L1.12191004,12.4286571 L3.22108675,12.4286571 L5.72505863,12.4286571 L5.25451647,15.0900857 Z M6.40706546,8.60292857 L3.78019398,8.60292857 L1.79833052,8.60292857 L2.05487269,7.15521429 C2.057451,7.1385 2.06088876,7.12221429 2.06432651,7.1055 L4.51415382,7.1055 L7.93514578,7.1055 C7.18958353,7.27092857 6.58926627,7.84521429 6.40706546,8.60292857 Z M28.0342149,23.9139 L25.5598936,23.9139 L25.5581747,23.9139 L16.0252912,23.9139 L16.7996446,19.5819 L30.8510221,19.5819 L32.9351586,19.5819 L33.3253434,19.5819 L35.4099096,19.5819 L48.0887651,19.5819 L50.5630863,19.5819 C50.4522189,20.1609 50.3718614,20.5774714 50.3718614,20.5774714 C50.0306647,22.5073286 48.3491747,23.9139 46.3849297,23.9139 L34.6441506,23.9139 L28.0342149,23.9139 Z M20.2615028,11.5970571 L18.2272137,11.5970571 L18.6139606,9.43448571 L20.649539,9.43448571 L23.2136715,9.43448571 L22.8252056,11.5970571 L20.2615028,11.5970571 Z M32.5594984,9.43452857 L34.6384783,9.43452857 L35.121912,9.43452857 L34.739892,11.5971 L32.1774783,11.5971 L30.1367434,11.5971 L30.5191932,9.43452857 L32.5594984,9.43452857 Z M19.6045486,15.7555286 L22.0788699,15.7555286 L21.4819904,19.0829571 L19.0068096,19.0829571 L16.889155,19.0829571 L17.4838859,15.7555286 L19.6045486,15.7555286 Z M29.4016663,15.7555286 L31.5300639,15.7555286 L34.0043851,15.7555286 L33.4161,19.0829571 L30.9417787,19.0829571 L28.3411201,19.0829571 C28.6896221,18.7868143 28.938859,18.3732429 29.0230839,17.8958143 L29.4016663,15.7555286 Z M19.694145,15.0900857 L17.6022735,15.0900857 L17.7101329,14.4913714 L18.078402,12.4286571 L20.1719924,12.4286571 L22.6759643,12.4286571 L22.1989763,15.0900857 L19.694145,15.0900857 Z M29.9895647,12.4286571 L32.0887414,12.4286571 L34.5927133,12.4286571 L34.1221711,15.0905143 L31.6181992,15.0905143 L29.5194522,15.0905143 L29.9895647,12.4286571 Z M23.3631277,8.60292857 L20.7392643,8.60292857 L18.7621277,8.60292857 L19.0302723,7.1055 L23.6321317,7.1055 L23.3631277,8.60292857 Z M32.7808466,7.10584286 L35.050192,7.10584286 L35.1868426,7.10584286 C35.2762241,7.58798571 35.3002884,8.0907 35.2500112,8.60284286 L34.7266137,8.60284286 L32.6476337,8.60284286 L30.4938827,8.60284286 C30.3159791,7.86784286 29.7324209,7.27555714 28.9743968,7.10584286 L32.7808466,7.10584286 Z M19.2084337,6.10765714 L16.7891165,6.10765714 L5.46086747,6.10765714 L2.35228112,6.10765714 C2.57100803,5.55651429 2.87610843,5.05165714 3.25125301,4.61065714 L13.8782008,4.61065714 L16.2558353,4.61065714 L17.054253,4.61065714 L19.4765783,4.61065714 L32.103008,4.61065714 L33.9972088,4.61065714 C34.3749317,5.05594286 34.6808916,5.5608 34.898759,6.10765714 L32.7119197,6.10765714 L26.4999036,6.10765714 L19.2084337,6.10765714 Z"
                id="Combined-Shape"
                fill="#F74020"
              ></path>
              <path
                d="M77.2456205,4.33478571 C76.0471345,4.33478571 75.0725321,3.36235714 75.0725321,2.16707143 C75.0725321,0.972214286 76.0471345,0.000214285714 77.2456205,0.000214285714 C78.4441064,0.000214285714 79.4187088,0.972214286 79.4187088,2.16707143 C79.4187088,3.36235714 78.4441064,4.33478571 77.2456205,4.33478571"
                id="Fill-49"
                fill="#F74020"
              ></path>
              <path
                d="M93.4394044,11.8138714 C92.4832799,13.6978714 91.5211394,15.4374429 90.5512639,17.0343 C89.5822478,18.6307286 88.6261233,20.1088714 87.6833201,21.4683 L99.1271635,21.4683 L100.496248,21.4683 C100.496248,21.4683 100.091023,19.7381571 100.038597,19.4908714 C99.8959305,18.8111571 99.751545,18.1395857 99.6067297,17.4765857 C99.4606253,16.8131571 99.3153803,16.1707286 99.1701353,15.5480143 C99.0248904,14.9257286 98.8886695,14.3685857 98.7614727,13.8774429 L101.775951,13.8774429 C101.94526,14.5001571 102.127031,15.2158714 102.319975,16.0271571 C102.512918,16.8375857 102.711878,17.6848714 102.916424,18.5698714 C103.117103,19.4403 103.307469,20.3278714 103.486232,21.2308714 C103.544244,21.4618714 103.554127,21.7155857 103.506429,21.9834429 C103.319501,23.0270143 102.331577,23.8743 101.28736,23.8974429 C101.285212,23.8983 101.281774,23.9000143 101.281774,23.9000143 L82.9508261,23.9000143 C83.6039988,22.9665857 84.2666253,21.9838714 84.9378462,20.9523 C85.6090671,19.9207286 86.2609506,18.8848714 86.8939265,17.8447286 C87.526043,16.8050143 88.1289386,15.7730143 88.7017538,14.7495857 C89.2749988,13.7261571 89.7988261,12.7477286 90.2745249,11.8138714 L84.2661956,11.8138714 L84.6933361,9.33287143 L106.838898,9.33287143 L106.394139,11.8138714 L93.4394044,11.8138714 Z M106.710327,2.77367143 L106.271584,5.23024286 L86.6592141,5.23024286 L87.0824871,2.77367143 L106.710327,2.77367143 Z M77.2456205,9.97525714 L63.6372831,9.97525714 L63.2402229,12.3769714 L64.8340502,12.3769714 L75.2444197,12.3769714 L76.8378173,12.3769714 L76.838247,12.3769714 L77.2456205,9.97525714 Z M76.0613153,16.9545429 L76.4557972,14.6278286 L76.4553675,14.6278286 L75.3866566,14.6278286 L63.9367972,14.6278286 L62.8676566,14.6278286 L62.8672269,14.6278286 L62.4821988,16.9545429 L62.4830582,16.9545429 L63.0111827,16.9545429 L75.532761,16.9545429 L76.0608855,16.9545429 L76.0613153,16.9545429 Z M75.4902189,20.3192571 L75.6745683,19.2315429 L75.6741386,19.2315429 L62.1061948,19.2315429 L61.7168695,21.5826857 L74.2646606,21.5826857 L74.3725201,21.5826857 L74.2646606,21.5826857 L74.3725201,21.5826857 L74.3733795,21.5822571 L75.2745,21.5822571 L75.4249016,20.6955429 L75.4889297,20.3196857 C75.4893594,20.3192571 75.4902189,20.3192571 75.4902189,20.3192571 Z M77.2456205,4.92154286 C78.4810622,4.92154286 79.5420382,4.19168571 80.0396526,3.14554286 L82.7559056,3.14554286 L82.3622831,5.4474 L72.8023273,5.4474 C72.6532149,5.83097143 72.4882028,6.21497143 72.3064317,6.59811429 C72.1242309,6.98211429 71.9364438,7.34854286 71.7430703,7.69868571 L80.37999,7.69868571 L77.935749,22.0279714 C77.935749,22.0279714 77.9331707,22.0318286 77.932741,22.0326857 C77.7475321,23.0664 76.7647651,23.9025429 75.7265643,23.9081143 L75.7239859,23.9094 L58.5979699,23.9094 L61.2660944,7.69868571 L68.2387129,7.69868571 C68.437243,7.31554286 68.626749,6.93582857 68.8068012,6.5604 C68.9872831,6.1854 69.158741,5.81468571 69.320745,5.4474 L59.9851024,5.4474 L60.3628253,3.14554286 L64.7313474,3.14554286 C64.6514197,2.81254286 64.5727811,2.47482857 64.495002,2.13282857 C64.4163635,1.79082857 64.3372952,1.50325714 64.2586566,1.27011429 L67.5172149,1.27011429 C67.6130422,1.50325714 67.7092992,1.78697143 67.8055562,2.1204 C67.9013835,2.45382857 67.9873273,2.79582857 68.0638173,3.14554286 L74.4515884,3.14554286 C74.9492028,4.19168571 76.0101787,4.92154286 77.2456205,4.92154286 Z"
                id="Combined-Shape"
                fill="#230D59"
              ></path>
            </g>
          </g>
        </g>
      </svg>
    </div>
    <div>
      <!-- <el-tooltip
        effect="light"
        :content="`切换${SYSTEM === 'eks-op' ? 'CCK' : 'EKS'}系统`"
        placement="bottom"
        class="m-r-50"
      >
        <el-button @click="FnChangeEntry()">
          <i class="el-icon-menu"></i>
        </el-button>
      </el-tooltip> -->
      OP切换：
      <el-select v-model="activePro" @change="FnChangeEntry" class="m-r-50 w-80">
        <el-option v-for="(item, index) in proList" :key="index" :label="item.name" :value="item.value"></el-option>
      </el-select>
      <el-dropdown trigger="click">
        <span class="el-dropdown-link">
          <i class="el-icon-user"></i>{{ username
          }}<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="FnLogout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </section>
</template>

<script>
import Service from '@/service/userInfo'
export default {
  data() {
    return {
      activePro: window.sessionStorage.getItem('SYSTEM') ?? 'cck-op',
      proList: [
        { name: 'CCK', value: 'cck-op' },
        { name: 'EKS', value: 'eks-op' },
        { name: 'ECI', value: 'eci-op' }
      ]
    }
  },
  computed: {
    username() {
      return this.$store.state.userInfo ? this.$store.state.userInfo.adAccount : ""
    },
    userAuth() {
      return this.$store.state.userAuth
    },
    OLD_SYSTEM() {
      return window.sessionStorage.getItem('OLD_SYSTEM') || '';
    },

    SYSTEM() {
      return window.sessionStorage.getItem('SYSTEM') || '';
    },
  },
  mounted() {
    this.$nextTick(() => {
      if (this.OLD_SYSTEM != this.SYSTEM) {
        this.$router.push('/')
        window.sessionStorage.setItem('OLD_SYSTEM', window.sessionStorage.getItem('SYSTEM') || '');
      }
    })
  },
  methods: {
    FnChangeEntry(val) {
      if(window.sessionStorage.getItem('SYSTEM') && window.sessionStorage.getItem('SYSTEM') === val) {
        return
      }
      window.sessionStorage.setItem('OLD_SYSTEM', window.sessionStorage.getItem('SYSTEM') || '');
      window.sessionStorage.setItem('SYSTEM', val);
      this.$store.SET_SYSTEM(val)
      
      window.location.reload()
      
    },
    FnLogout() {
      this.$confirm('是否退出当前账号？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let reqData = {
          token: this.$store.state.token
        }
        Service.logout(reqData).then(resData => {
          if (resData.code == "Success") {
            this.$router.go(0)
          }
        })
      }).catch(() => { })
    }
  }
}
</script>

<style lang="scss" scoped>
.page-head {
  display: flex;
  justify-content: space-between;
  line-height: 46px;
  svg {
    width: 80px;
    vertical-align: middle;
  }
  .el-icon-user {
    margin-right: 6px;
  }
}
</style>